<!-- Horizontal Form -->
 <div class="box box-info">
      <div class="box-header with-border">
        <h3 class="box-title">修改密码</h3>
      </div>
      <!-- /.box-header -->
      <!-- form start -->
      <form class="form-horizontal" id="pwd-app">
        <div class="box-body">
          <div class="form-group">
            <label for="pwdId" class="col-sm-2 control-label">原密码</label>
            <div class="col-sm-10">
              <input type="password" v-model="password" class="form-control" name="password" id="pwdId" placeholder="原密码">
            </div>
          </div>
          <div class="form-group">
            <label for="newPwdId" class="col-sm-2 control-label">新密码</label>

            <div class="col-sm-10">
              <input type="password"  v-model="newPassword" class="form-control" name="newPwd" id="newPwdId" placeholder="新密码">
            </div>
          </div>
          <div class="form-group">
            <label for="cfgPwdId" class="col-sm-2 control-label">密码确认</label>

            <div class="col-sm-10">
              <input type="password" v-model="newPassword2" class="form-control" name="cfgPwd" id="cfgPwdId" placeholder="密码确认">
            </div>
          </div>
         
        </div>
        <!-- /.box-body -->
        <div class="box-footer">
          <button type="button" class="btn btn-default btn-cancel" @click="cancle">取消</button>
          <button type="button" class="btn btn-info pull-right btn-save" @click="savepwd">保存</button>
        </div>
        <!-- /.box-footer -->
      </form>
    </div>
   
<script type="text/javascript">
  let pwdApp= new Vue({
    el:"#pwd-app",
    data:{
      password:'',
      newPassword:'',
      newPassword2:''
    },
    methods:{
      cancle:function () {
        location.href="/admin";
      },
      savepwd:function () {
        let password=this.password;
        if(!password){
          alert("原密码不为空!");
          return;
        }
        let newPassword=this.newPassword;
        if(!newPassword){
          alert("新密码不为空!");
          return;
        }
        let newPassword2=this.newPassword2;
        if(!newPassword2){
          alert("新密码确认不为空!");
          return;
        }
        if(newPassword!=newPassword2){
          alert("新密码和新密码确认不一样,请重新输入!");
          return;
        }
        let form = new FormData();
        form.append("password",password);
        form.append("newPassword",newPassword);
        axios({
          url:'/sys-users/pwdEdit',
          method:'post',
          data: form
        }).then(res=>{
          var result=res.data;
          console.log(result);
          if(!result.message){
            alert("修改密码成功!");
            location.href="/admin";
            return ;
          }else{
            alert(result.message);
          }

        }).catch(e=>console.error(e.message))




      }


    }

  })

 
</script>
    
    
    
    
    
    
    